﻿using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;

using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Nemerle2.Compiler;

namespace Test
{
  /// <summary>
  /// Description of UniqueKeyTests.
  /// </summary>
  [TestFixture]
  public class UniqueKeyTests : AssemblyTests
  {
    [Test]
    public TestTypes() : void
    {
      def s = HashSet();

      def assemblies = AllAssembliesProject.LoadedAssemblies;

      foreach(assembly in assemblies)
      {
        foreach(ty in assembly.AllTypes)
        {
          Assert.IsTrue(s.Add(ty.UniqueKey), "A type UniqueKey @(ty.UniqueKey) already exists");

          foreach(member in ty.GetMembers().Where(m => !(m is ITypeInfo)))
            Assert.IsTrue(s.Add(member.UniqueKey), "A member UniqueKey $(member.UniqueKey) already exists");
        }
      }
    }
  }
}
